<template>
    <el-dialog :title="title" :visible.sync="dialogVisible" width="50%" :before-close="handleClose" append-to-body>
        <div style="margin-left: 30px;">
            <el-transfer v-model="value" :data="data" :titles="['基本信息', '基本']" :render-content="renderFunc"></el-transfer>
        </div>

        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
        </span>
    </el-dialog>
</template>

<script>
import { getSzbzpbyjPersonList, getRemindPerson } from "@/api/young/echarts/cadre/cadreNew";
import store from "@/store";
export default {
    name: "essential",
    data() {
        return {
            data: [],  // 初始化数据为空数组
            value: [],
            title: "穿梭框基本信息",
            dialogVisible: false,
            paramsList: [],//条件
            alertPar: "",//标题
        };
    },
    methods: {
        init(param, alertPar) {
            console.log(param, alertPar, "孙组件");
            this.generateData(param, alertPar);  // 在组件创建时调用生成数据的方法
            this.dialogVisible = true;
        },
        handleClose() {
            this.dialogVisible = false;
        },
        generateData(param, alertPar) {
            var that = this;
            that.dialogVisible = true;
            that.paramsList = param;
            that.alertPar = alertPar;
            if (param.all != "true") {
                param["page"] = 1
                param["rows"] = 10
            } else {
                delete param.page;
                delete param.rows;
            }
            if (that.paramsList.showType == "getSzbzpbyjPersonList") {
                that.loading = true;
                getSzbzpbyjPersonList(param).then(function (result) {
                    if (result.result) {
                        const list = [];
                        result.resultdata.data.forEach(function (obj) {
                            list.push({
                                key: obj.COUNT,
                                label: obj.xingming + "_" + obj.xingbie,
                            });
                        });
                        that.data = list;
                    }
                });
            } else if (that.paramsList.showType == 'rxcb') {
                getRemindPerson(param).then(function (result) {
                    if (result.result) {
                        const list = [];
                        result.resultdata.data.forEach(function (obj) {
                            list.push({
                                key: obj.COUNT,
                                label: obj.xingming + "_" + obj.xingbie,
                            });
                        });

                        that.data = list;
                    }
                })
            }
        },
        renderContent(h, option) {
            console.log(h,option,"q23");
            // return h("div", {}, [
            //     h("span", { style: "margin-right: 10px;" }, option.label),
            //     h("span", { style: "color: #666;" }, "[详细信息1:" + option.data.key + "]"),
            //     h("span", { style: "color: #666;" }, "[详细信息2:" + option.data.customProp1 + "]"),
            //     // 可以根据实际需求添加其他需要展示的内容
            // ]);
        },
    },
};
</script>

<style scoped>
>>>.el-transfer-panel {
    width: 350px !important;
}
</style>